package org.example.com.zwh.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.example.com.zwh.entity.SeckillOrder;

@Mapper
public interface SeckillOrderMapper extends BaseMapper<SeckillOrder> {

    //查询方法
    @Select("select * from t_seckill_order where user_id = #{userId} and activity_id = #{activityId}")
    @Results({
            @Result(column = "user_id", property = "userId"),
            @Result(column = "activity_id", property = "activityId"),
            @Result(column = "create_time", property = "createTime")
    })
    SeckillOrder getSeckillOrderByUserIdAndActivityId(String userId, String activityId);

    //增加订单
    @Insert("insert into t_seckill_order(id, user_id, activity_id, status) values( #{id}, #{userId},#{activityId}, #{status})")
    int insert(SeckillOrder seckillOrder);

    @Delete("delete from t_seckill_order where user_id = #{userId} and activity_id = #{activityId}")
    void deleteByUserIdAndActivityId(String userId, String productId);

    @Update("update t_seckill_order set status = #{status} where user_id = #{userId} and activity_id = #{activityId}")
    void updateStatusByUserIdAndActivityId(String userId, String productId, String i);
    //修改订单状态
    @Update("update t_seckill_order set status = #{status} where user_id = #{userId} and activity_id = #{activityId}")
    void updateOrderStatus(String userId, String productId, String status);

    @Update("UPDATE t_seckill_order SET status=#{status} WHERE id=#{id}")
    int updateById(@Param("id") String id, @Param("status") String status);
}
